package leetcode93双周赛;

/**
 * @author aodre , QQ : 480029069
 * @date 2022/12/11 9:39
 */
public class leetcode6261 {
    /*
     *可以使用异常来处理， try catch
     */
    public int solutionOne(String strs[]){
        int ans = 0 ;
        int temp = 0;
        for(int i = 0;i < strs.length;i++){
            try {
                temp = Integer.parseInt(strs[i]);
            } catch (NumberFormatException e) {
//                e.printStackTrace();
                temp = strs[i].length();
            }
            ans = Math.max(ans,temp);
        }
        return ans;
    }









    // 中规中矩的 思路 写
    public int solution(String strs[]){
        int ans = 0;
        for(int i = 0;i < strs.length;i++){
            ans = Math.max(ans,judge(strs[i]) ? Integer.parseInt(strs[i]) : strs[i].length());
        }
        return ans;
    }
    public boolean judge(String str){
        for(int i = 0;i < str.length();i++){
            if(!(str.charAt(i) <= '9' && str.charAt(i) >= '0'))
                return false;

        }
        return true;
    }

}
